﻿<Window x:Class="SuplexApp.RightRoleDlg" Name="rrDlg"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:splxApi="clr-namespace:Suplex.Forms.ObjectModel.Api;assembly=Suplex.Core"
        Title="Right Role" Height="400" Width="700"
        Closing="Window_Closing">
    <Grid Margin="10,0,10,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="43" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="10"/>
            <ColumnDefinition Width="350"/>
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="0" Grid.ColumnSpan="3" Margin="0,10" VerticalAlignment="Stretch" TextWrapping="Wrap"
                   Text="Convert the resultant security for [Source UI Element]/[SourceType]/[Right] and create a [UI Ace]/[Right] for [Destination UI Element]." />

        <Grid Grid.Row="1" Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <TextBlock Text="Destination UI Element"/>
            <TreeView Name="tvUIElements" Grid.Row="1" VerticalAlignment="Stretch"
                      SelectedItemChanged="tvUIElements_SelectedItemChanged" ItemsSource="{Binding}">
                <TreeView.Resources>
                    <HierarchicalDataTemplate DataType="{x:Type splxApi:UIElement}" ItemsSource="{Binding Path=UIElements}">
                        <TextBlock Text="{Binding Path=Name}" />
                    </HierarchicalDataTemplate>
                    <Style TargetType="TreeViewItem">
                        <!-- IsSelectedAlternate is used as IsSelected causes some fun corresponding behaviors on the MainDlg UieTree -->
                        <Setter Property="IsSelected" Value="{Binding Path=IsSelectedAlternate, Mode=TwoWay}"/>
                        <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded}"/>
                    </Style>
                </TreeView.Resources>
            </TreeView>
        </Grid>


        <Grid Grid.Row="1" Grid.Column="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>

            <Grid Grid.Row="0" Grid.Column="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <TextBlock Text="Source Type"/>
                <ListBox Grid.Row="1" Name="lstSrcAceType" SelectionChanged="lstSrcAceType_SelectionChanged"
                     SelectedItem="{Binding ElementName=rrDlg, Path=DataContext.AceType, UpdateSourceTrigger=Explicit}"/>
            </Grid>

            <Grid Grid.Row="0" Grid.Column="1" Margin="10,0,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <TextBlock Text="Source Right"/>
                <ListBox Name="lstSrcRight" Grid.Row="1" Grid.Column="0" SelectionChanged="Something_Changed"
                     SelectedItem="{Binding ElementName=rrDlg, Path=DataContext.Right, UpdateSourceTrigger=Explicit}"/>
            </Grid>

            <Grid Grid.Row="1" Grid.Column="0" Margin="0,10,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0" Text="Destination UI Right"/>
                <ListBox Grid.Row="1" Name="lstDstRight" SelectionChanged="Something_Changed"
                     SelectedItem="{Binding ElementName=rrDlg, Path=DataContext.UIRight, UpdateSourceTrigger=Explicit}"/>
            </Grid>
        </Grid>

        <Canvas Grid.Row="2" Grid.Column="2">
            <Button Name="cmdOk" Content="Add" Canvas.Bottom="10" Canvas.Right="95" Height="23" Width="75" Click="cmdOk_Click" IsDefault="False"/>
            <Button Name="cmdClose" Content="Close" Canvas.Bottom="10" Canvas.Right="10" Height="23" Width="75" Click="cmdClose_Click" IsCancel="True"/>
        </Canvas>
    </Grid>
</Window>